from datetime import datetime
import time
import sys

outfile = sys.argv[1]

# Get current time with milliseconds
while True:
    current_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')[:-3]
    with open(outfile, 'w') as f:
        f.write(current_time) # Output: '2023-12-01 10:34:18.657'
    time.sleep(1)
